package com.sinai.mshab.format.validation;

import java.util.HashSet;
import java.util.Set;

import com.sinai.mshab.format.util.Observer;

/**
 * This concrete implementation of {@link Validator} only deals with handling
 * adding and removing {@link Observer}s (but not notifying them).
 * 
 * @author Arthur Kalmenson
 * 
 * @param <T>
 *            the type of widget this validator deals with.
 */
public abstract class AbstractValidatorImpl<T> implements Validator<T> {

	/**
	 * The {@link Set} of observers that are observing this {@link Validator}.
	 */
	private Set<Observer> observers = new HashSet<Observer>();

	public void addObserver(Observer observer) {
		observers.add(observer);
	}

	public int countObservers() {
		return observers.size();
	}

	public void deleteObserver(Observer observer) {
		observers.remove(observer);
	}

	public void deleteObservers() {
		observers.clear();
	}
}
